package com.cy.sc.config;

import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;
/**
 * <br>@class: ConfigBean
 * <br>@description: boot配置bean，加载RestTemple,注入ribbon
 * <br>@author: cy
 * <br>@date: 2020-04-03 18:32:14
 * <br>@version: 1.0
 * <br>
 * <br>@since: (版本) 作者 时间 注释
 */
@Configuration
public class ConfigBean {
    //配置负载均衡实现RestTemple
    //核心实现 IRule接口
    //RoundRobinRule 轮训 默认
    //RandomRule 随机
    //AvailabilityFilteringRule 过滤后轮训
    //WeightedResponseTimeRule 权重后轮训
    @Bean
    @LoadBalanced  //这就是 Ribbon
    public RestTemplate getRestTemplate() {
        return new RestTemplate();
    }

}
